using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class DurationCategoriesAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public DurationCategoriesAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.User;
						tableVersionTypes[HL7Version.v24] = HL7TableType.User;
						tableVersionTypes[HL7Version.v25] = HL7TableType.User;
						tableVersionTypes[HL7Version.v251] = HL7TableType.User;
						tableVersionTypes[HL7Version.v26] = HL7TableType.User;
						tableVersionTypes[HL7Version.v27] = HL7TableType.User;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{""};
						validVersionCodes[HL7Version.v231] = new string[]{"PT","* (star)","30M","1H","2H","2.5H","3H","4H","5H","6H","7H","8H","12H","24H","2D","3D","4D","5D","6D","1W","2W","3W","4W","1L","2L","3L"};
						validVersionCodes[HL7Version.v24] = new string[]{"PT","*","30M","1H","2H","2.5H","3H","4H","5H","6H","7H","8H","12H","24H","2D","3D","4D","5D","6D","1W","2W","3W","4W","1L","2L","3L"};
						validVersionCodes[HL7Version.v25] = new string[]{"PT","*","30M","1H","2H","2.5H","3H","4H","5H","6H","7H","8H","12H","24H","2D","3D","4D","5D","6D","1W","2W","3W","4W","1L","2L","3L"};
						validVersionCodes[HL7Version.v251] = new string[]{"PT","*","30M","1H","2H","2.5H","3H","4H","5H","6H","7H","8H","12H","24H","2D","3D","4D","5D","6D","1W","2W","3W","4W","1L","2L","3L"};
						validVersionCodes[HL7Version.v26] = new string[]{"PT","*","30M","1H","2H","2.5H","3H","4H","5H","6H","7H","8H","12H","24H","2D","3D","4D","5D","6D","1W","2W","3W","4W","1L","2L","3L"};
						validVersionCodes[HL7Version.v27] = new string[]{"PT","*","30M","1H","2H","2.5H","3H","4H","5H","6H","7H","8H","12H","24H","2D","3D","4D","5D","6D","1W","2W","3W","4W","1L","2L","3L"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{""};
						validVersionDescriptions[HL7Version.v231] = new string[]{"To identify measures at a point in time.  This is a synonym for \"spot\" or \"random\" as applied to urine measurements.","Life of the \"unit.\"  Used for blood products.","30 minutes","1 hour","2 hours","2½ hours","3 hours","4 hours","5 hours","6 hours","7 hours","8 hours","12 hours","24 hours","2 days","3 days","4 days","5 days","6 days","1 week","2 weeks","3 weeks","4 weeks","1 months (30 days)","2 months","3 months"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"To identify measures at a point in time.  This is a synonym for \"spot\" or \"random\" as applied to urine measurements.","(asterisk) Life of the \"unit.\"  Used for blood products.","30 minutes","1 hour","2 hours","21/2 hours","3 hours","4 hours","5 hours","6 hours","7 hours","8 hours","12 hours","24 hours","2 days","3 days","4 days","5 days","6 days","1 week","2 weeks","3 weeks","4 weeks","1 months (30 days)","2 months","3 months"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"To identify measures at a point in time.  This is a synonym for \"spot\" or \"random\" as applied to urine measurements.","(asterisk) Life of the \"unit.\"  Used for blood products.","30 minutes","1 hour","2 hours","2½ hours","3 hours","4 hours","5 hours","6 hours","7 hours","8 hours","12 hours","24 hours","2 days","3 days","4 days","5 days","6 days","1 week","2 weeks","3 weeks","4 weeks","1 months (30 days)","2 months","3 months"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"To identify measures at a point in time.  This is a synonym for \"spot\" or \"random\" as applied to urine measurements.","(asterisk) Life of the \"unit.\"  Used for blood products.","30 minutes","1 hour","2 hours","2Â½ hours","3 hours","4 hours","5 hours","6 hours","7 hours","8 hours","12 hours","24 hours","2 days","3 days","4 days","5 days","6 days","1 week","2 weeks","3 weeks","4 weeks","1 months (30 days)","2 months","3 months"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"To identify measures at a point in time.  This is a synonym for \"spot\" or \"random\" as applied to urine measurements.","(asterisk) Life of the \"unit.\"  Used for blood products.","30 minutes","1 hour","2 hours","2Â½ hours","3 hours","4 hours","5 hours","6 hours","7 hours","8 hours","12 hours","24 hours","2 days","3 days","4 days","5 days","6 days","1 week","2 weeks","3 weeks","4 weeks","1 months (30 days)","2 months","3 months"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"To identify measures at a point in time.  This is a synonym for \"spot\" or \"random\" as applied to urine measurements.","(asterisk) Life of the \"unit.\"  Used for blood products.","30 minutes","1 hour","2 hours","2Â½ hours","3 hours","4 hours","5 hours","6 hours","7 hours","8 hours","12 hours","24 hours","2 days","3 days","4 days","5 days","6 days","1 week","2 weeks","3 weeks","4 weeks","1 months (30 days)","2 months","3 months"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
